<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <title>管理平台</title>
    <link rel="stylesheet" href="${base}/static/layui/css/layui.css"/>
    <link rel="stylesheet" href="${base}/static/css/admin.css"/>
</head>
<body>
<div class="container">
    <div class="content-search">
        <form class="layui-form layui-form-pane" action="${base}/broker/list">
            <div class="layui-inline">
                <label class="layui-form-label" >客户</label>
                <div class="layui-input-block">
                    <input name="user" value="${user!}"  autocomplete="off" placeholder="客户姓名/手机号" class="layui-input" type="text"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" >业务员</label>
                <div class="layui-input-block">
                    <input name="puller" value="${puller!}"  autocomplete="off" placeholder="业务员姓名/手机号" class="layui-input" type="text"/>
                </div>
            </div>

            <div class="layui-inline"><button class="layui-btn" lay-submit="" type="submit">查询</button></div>
        </form>
    </div>
    <div class="tar mt10">
      <!--  <button class="layui-btn layui-btn-normal layui-btn-small add">+添加客户</button>-->
    </div>
    <div class="table-listm roll-x">
        <table class="layui-table" lay-skin="line">
            <thead>
            <tr>
                <th>客户姓名</th>
                <th>客户手机号</th>
                <th>业务员姓名</th>
                <th>业务员手机号</th>
                <th>开始时间</th>
                <th>结束时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <% for(l in list){%>
            <tr>
                <td>${l.name}</td>
                <td>${l.phone}</td>
                <td>${l.pullerName}</td>
                <td>${l.pullerPhone}</td>
                <td>${l.startDate,dateFormat="yyyy-MM-dd HH:mm:ss"}</td>
                <td>${l.endDate,dateFormat="yyyy-MM-dd HH:mm:ss"}</td>
                <td>
                    无操作
                </td>
            </tr>
            <%}%>
            </tbody>
        </table>
    </div>
</div>
<div id="table-pages" style="text-align:center"></div>
<script type="text/javascript" src="${base}/static/layui/jquery.min.js"></script>
<script type="text/javascript" src="${base}/static/layui/layui.js"></script>
<script type="text/javascript" src="${base}/static/js/jquery.form.js"></script>
<script type="text/javascript" src="${base}/static/js/util.js"></script>

<script>
    function freezeOrUnfreeze(userId) {
        $.ajax({
            type : "POST", //提交方式
            url : "${base}/admin/freezeOrUnfreeze",//路径
            data : {
                "userId" : userId
            },//数据，这里使用的是Json格式进行传输
            success : function(data) {//返回数据根据结果进行相应的处理
                if(data.code==200){
                    layer.msg('操作成功！',{time: 2000});

                }else{
                    layer.msg(data.message,{time: 2000});
                }
            }
        });
    }
    layui.use(['jquery', 'laydate','form','layer','laypage'], function(){
        var $ = layui.jquery,
            laydate = layui.laydate,
            layer = layui.layer,
            laypage = layui.laypage;
        // 分页
        laypage({
            cont: 'table-pages'
            ,pages:${page.pages}
            ,skip: true
            ,curr:${page.pageNum}
            ,jump:function(e,first){
                if(!first){
                    var myform=$('.layui-form'); //得到form对象
                    var tmpInput=$("<input type='text' name='pageNum'/>");
                    tmpInput.attr("value", e.curr);
                    myform.append(tmpInput);
                    myform.submit();
                }
            }
        });

        // 冻结操作
        $(document).on("click", ".a4", function() {
            var userId=this.id;
            layer.open({
                title:"冻结操作"
                ,content: '您确认要冻结管理员吗？'
                ,btn: ['取消', '确认']
                ,yes: function(index, layero){
                    layer.closeAll();
                }
                ,btn2: function(index, layero){
                    freezeOrUnfreeze(userId);
                    thisWindowReload(1000);

                }
            });
        });
        // 解冻操作
        $(document).on("click", ".a1", function() {
            var userId=this.id;
            layer.open({
                title:"解冻操作"
                ,content: '您确认要解冻该管理员吗？'
                ,btn: ['取消', '确认']
                ,yes: function(index, layero){
                    layer.closeAll();
                }
                ,btn2: function(index, layero){
                    freezeOrUnfreeze(userId);
                    thisWindowReload(1000);
                }
            });
        });

        // 发布商品
        $(document).on("click", ".add", function() {
            layer.open({
                type:2
                ,area:['80%', '90%']
                ,title:"添加管理员"
                ,content: '${base}/user/addUser'
            });
        });

        // 修改客户
        $(document).on("click", ".edit", function() {
            var id=this.id;
            layer.open({
                type:2
                ,area:['80%', '90%']
                ,title:"编辑管理员"
                ,content: '${base}/user/addUser?id='+id
            });
        });

    });
</script>
</body>
</html>